<fieldset><legend>Filtros</legend>
<?php 	
	$this->Html->script(array('jquery.maskedinput-1.2.2.min','maskinput','jquery.ui.datepicker-pt-BR','datepicker'), false);
	
	echo $this->Form->create('Agenda', array('target' => '_blank'));
	echo $this->Form->input('data_inicial', array('label' => __('Data Inicial'), 'type' => 'text', 'class' => 'maskdata data'));
	echo $this->Form->input('data_final', array('label' => __('Data Final'), 'type' => 'text', 'class' => 'maskdata data'));
	echo $this->Form->input('medico_id', array('label' => __('Médico'), 'type' => 'select', 'options' => $medicos, 'empty' => 'Todos',  'class' => 'tamanho50'));
	echo $this->Form->input('situacao', array('type' => 'select', 'options' => $situacoes, 'empty' => __('Todas'), 'label' => __('Situação')));
	echo $this->Form->input('solicita_adiantamento', array('type' => 'select', 'options' => $solic_adiantamento, 'empty' => __('Qualquer situação'), 'class' => 'tamanho20', 'label' => __('Solicita Adiantamento')));
	echo $this->Form->input('exibir_telefones', array('type' => 'checkbox', 'label' => __('Exibir telefones do paciente')));
	echo '<div style="clear:both;padding-top:20px;"></div>';
	echo $this->Form->button('Imprimir', array('type' => 'submit'));
	echo $this->Form->end();
?>
</fieldset>

<script>

	$('#AgendaDataInicial,#AgendaDataFinal').change(function(){

		if (!$('#AgendaDataFinal').val()) {
			$('#AgendaDataFinal').val($('#AgendaDataInicial').val());
		}
		
		$.ajax({
			type: 'POST',
			url: root() + '/agendas/buscar_medicos_por_data/options',
			async: true,
			data: {
				data_inicial : $('#AgendaDataInicial').val(),
				data_final : $('#AgendaDataFinal').val()
			},
			beforeSend : function() {
				$('#AgendaMedicoId').html('<option>Carregando...</option>');
			},
			success: function(retorno){
				$('#AgendaMedicoId').html(retorno);
			}
		});	

	});

</script>	